<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <button-a></button-a>
        <button-a></button-a>

    </div>

    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script>

        
        

        Vue.component('button-a',{
            data() {
                return {
                    count:0
                }
            },
            methods:{
                countPlus:function () { 
                    this.count++;    
                }
            },
            template: 
            `
                <button @click="countPlus()">
                    点击量:{{count}}
                </button>
            `
        });//每个复用的组件完全独立，互不干涉
        //全局组件，不同的vue实例都可以使用

        var app = new Vue({
            el:"#app",
            components: {
                'button-b': {
                    data() {
                        return {
                            count:0
                        }
                    },
                    methods:{
                        countPlus:function () { 
                            this.count++;    
                        }
                    },
                    template: 
                    `
                        <button @click="countPlus()">
                            点击量:{{count}}
                        </button>
                    `
                }
            },//局部组件，只能在挂载的vue实例中使用
            //可以直接写
            data:{
                
            },
            methods: {
                
            },
        })
    </script>

</body>
</html>